<?php

namespace App\Http\Resources\barber;

use Illuminate\Http\Resources\Json\ResourceCollection;

class OrderCollection extends ResourceCollection
{
    /**
     * Transform the resource collection into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return $this->collection->map(function ($item) {
            return [
                'id' => $item->id,
                'img' => $item->type,
                'amount' => $item->amount,
                'date' => $item->date,
                'time' => $item->time,
                'status' => $item->status,
                'evaluate' => $item->evaluate,
                'status_text' => $item->status_text,
                'shop' => [
                    'id' => $item->shop->id,
                    'name' => $item->shop->name,
                    'img' => $item->shop->img,
                ],
                'barber' => [
                    'id' => $item->barber->id,
                    'name' => $item->barber->name
                ]

            ];
        });
    }
}
